feat: pass _meta parameter through to MCP SDK call_tool#412
Open
Peter Houghton (peter-houghton) wants to merge 1 commit intolangchain-ai:mainfrom
Open
feat: pass _meta parameter through to MCP SDK call_tool#412Peter Houghton (peter-houghton) wants to merge 1 commit intolangchain-ai:mainfrom
Peter Houghton (peter-houghton) wants to merge 1 commit intolangchain-ai:mainfrom
Conversation
This change enables the MCP protocol's _meta parameter to be passed through to MCP servers when invoking tools. The _meta field is part of the MCP specification and allows clients to attach additional metadata to their requests. Per the MCP spec (2025-06-18), _meta is reserved to allow clients and servers to attach additional metadata to their interactions. This includes: - Custom routing and context information - Server-specific metadata for multi-tenant or federated scenarios Changes: - Add 'meta' field to MCPToolCallRequest dataclass - Add 'meta' to _MCPToolCallRequestOverrides for interceptor support - Extract _meta from tool arguments and pass to session.call_tool() - Add tests for _meta passthrough functionality - Add documentation for _meta usage in README
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_metaparameter to be passed through to MCP servers when invoking toolsmetafield toMCPToolCallRequestdataclass and_MCPToolCallRequestOverridesfor interceptor support_metafrom tool arguments and passes it tosession.call_tool()Related Issue
Proposal for #410
How It Works
When invoking an MCP tool, you can include a
_metafield in the tool arguments. This metadata is extracted from the arguments and passed through to the MCP server viasession.call_tool().For example, to pass a correlation ID or user ID for tracing/auditing purposes:
The MCP server receives the
_metaobject as part of theCallToolRequest, allowing it to:Changes
metafield toMCPToolCallRequestdataclassmetato_MCPToolCallRequestOverridesfor interceptor support_metafrom tool arguments and pass tosession.call_tool()_metapassthrough functionality_metausage in READMEMCP Specification Reference
Per the MCP spec (2025-06-18),
_metais reserved to allow clients and servers to attach additional metadata to their interactions, including: